package io.openmessaging;

public class 外观数列 {
    public static void main(String[] args) {
        String s="111221";
        char k=s.charAt(0);
        int count=0;
        StringBuilder result=new StringBuilder();
       for(int i=0;i<s.length();i++){
           if(s.charAt(i)==k){
               count++;

           }else
           {
               result.append(count).append(k);
               count=1;
               k=s.charAt(i);
           }
           if(i==s.length()-1){
               result.append(count).append(k);
           }

       }
       System.out.println(result);
    }
}
